package com.yogee.topseller.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yogee.core.base.HttpActivity;
import com.yogee.core.http.listener.HttpOnNextListener;
import com.yogee.core.http.subscribers.BaseSubscriber;
import com.yogee.core.utils.ToastUtils;
import com.yogee.topseller.R;
import com.yogee.topseller.adapter.DingyueAdapter;
import com.yogee.topseller.bean.DingyueBean;
import com.yogee.topseller.bean.EventBean;
import com.yogee.topseller.bean.ResultBean1;
import com.yogee.topseller.fragment.collect.CollectBodyFragment;
import com.yogee.topseller.fragment.collect.CollectBodyOtherFragment;
import com.yogee.topseller.fragment.product.model.bean.ProductListBean;
import com.yogee.topseller.fragment.zhoubian.DeleteDyFragment;
import com.yogee.topseller.fragment.zhoubian.DingyueFragment;
import com.yogee.topseller.http.HttpManager;
import com.yogee.topseller.utils.AppUtil;
import com.yogee.topseller.utils.RefreshUtil;
import com.yogee.topseller.utils.TabLayoutUtil;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * 收藏
 *
 * @author hanyu
 *         created by 2017/7/11 17:32
 */
public class ShoucangActivity extends HttpActivity {

    Unbinder unbinder;
    @BindView(R.id.collect_layout)
    LinearLayout collectLayout;
    @BindView(R.id.collect_vp)
    ViewPager collectVp;
    private CollectBodyFragment bodyFragment;
    private CollectBodyOtherFragment bodyOtherFragment;
    private List<String> titles;
    private List<Fragment> fragments;
    private String types = "0";

    @Override
    protected int getLayoutId() {
        return R.layout.activity_shoucang;
    }

    @Override
    protected void initView() {
        types = getIntent().getStringExtra("types");
        collectVp.setOffscreenPageLimit(1);
        titles = new ArrayList<>();
        fragments = new ArrayList<>();
        titles.add("收藏");
        titles.add("分享");
        titles.add("浏览");
        titles.add("搜索");
        titles.add("对比");
        titles.add("PK");

        for (int i = 0; i < 3; i++) {
            Bundle bundle = new Bundle();
            bundle.putInt("collectType",i);
            bodyFragment = new CollectBodyFragment();
            bodyFragment.setArguments(bundle);
            fragments.add(bodyFragment);
        }
        for (int i = 0; i < 3; i++) {
            Bundle bundle = new Bundle();
            bundle.putInt("collectType",i);
            bodyOtherFragment = new CollectBodyOtherFragment();
            bodyOtherFragment.setArguments(bundle);
            fragments.add(bodyOtherFragment);
        }
        new TabLayoutUtil(getSupportFragmentManager(), collectLayout, fragments, titles, 100,types);
    }

    @Override
    protected void onResume() {
        super.onResume();
//        loadCompareData();
    }

    /**
     * 获取对比产品列表
     */
    private void loadCompareData() {
        HttpManager.getInstance().loadCompareProducts(AppUtil.getUserId(this)).compose(this.bindRecycler()).subscribe(new BaseSubscriber(new HttpOnNextListener<ProductListBean>() {
            @Override
            public void onNext(ProductListBean o) {
                if ("1".equals(o.getResult())) {
                    if (null != o.getProductList() && o.getProductList().size() > 0) {
//                        addCompareList(o.getProductList());
                    }
                }
            }
        }, this));
    }



    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    }

    @OnClick({R.id.img_return})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_return:
                ShoucangActivity.this.finish();
                break;

        }
    }




}
